import { SET_USER_INFO } from '../actionTypes/user';

const initialState = {
  userInfo: {
    name: 'test name',
  },
};

const actionHandlers = {
  [SET_USER_INFO](state, action) {
    return { ...state, userInfo: action.userInfo };
  },
};

const reducer = (state = initialState, action) => {
  const { type, data } = action;
  const actionHandler = actionHandlers[type];
  return actionHandler ? actionHandler(state, data) : state;
};

export default reducer;
